﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DebugTools
{
    class ACS_Chroma:ACSource
    {
        List<string> _ListTypes;
        public ACS_Chroma(string szInsID):base(szInsID)
        {
            _szErrCmd = "SYST:ERR?\n";
            _szErrRet = "0,No Error\r\n";
            _ListTypes = new List<string>();           
        }

        public override bool Init()
        {
            bool bRet = false;
            _ListTypes.Add("Chroma ATE,6530");  //Chroma ATE,6530,11580,3.70

            for (int i = 0; i < _ListTypes.Count; i++)
            {
                bRet = this.QueryType().Contains(_ListTypes[i]);
                if (bRet)
                {
                    _szType = _ListTypes[i];
                    break;
                }
            }

            return base.Init();
        }

        public override void Set_VF(string Volt, string Frequency)
        {
            _szCmd = "SOUR:VOLT " + Volt + ";FREQ " + Frequency + "\n";
                this.Write(_szCmd);
            if (Volt.Equals("0") || Frequency.Equals("0"))
                this.ONorOFF(false);
            else
                this.ONorOFF(true);
        }

        public override double Meas_Volt()
        {
            _szCmd = "MEAS:VOLT:AC?\n";
            return base.Meas_Volt();
        }

        public override double Meas_Curr()
        {
            _szCmd = "MEAS:CURR:AC?\n";
            return base.Meas_Curr();
        }

        public override double Meas_Power()
        {
            _szCmd = "MEAS:POW:AC?\n";
            return base.Meas_Power();
        }

        public override void ONorOFF(bool NF)
        {
            _szCmd = NF ? "OUTP ON\n" : "OUTP OFF\n";
            this.Write(_szCmd);
        }

        public override bool QueryState()
        {
            return base.QueryState();
        }
    }
}
